import Home from '@/views/Home'
import Category from '@/views/Category'
import Cart from '@/views/Cart'
import User from '@/views/User'
import Tabbar from '@/components/Tabbar'
import Navbar from '@/components/Navbar'
import SubCategories from '@/components/Subcategory'
import Detail from '@/views/Detail'
import List from '@/views/List'
import Login from '@/views/Login'

const routes = [
  {
    path: '/',
    redirect: '/home', // 路由重定向
    meta: {}
  },
  {
    path: '/home',
    // component: Home
    components: {
      default: Home, // default 为未命名的 <router-view />
      appFooter: Tabbar // appFooter 为命名的 <router-view name="appFooter" />
    }
    // mata: { // 携带的额外数据
    //   isNav: true, // 是否为taabar的导航
    //   title: '首页', // 标题
    //   icon: '&#xe618;' // 图标
    // }
  },
  {
    path: '/category',
    components: {
      default: Category,
      appFooter: Tabbar
    },
    children: [
      {
        path: 'subcategory/:suibianqu',
        name: 'subcategory',
        component: SubCategories
      }
    ]
  },
  {
    path: '/list/:url',
    name: 'list',
    components: {
      default: List,
      appHeader: Navbar
    },
    meta: {
      title: '商品列表'
    }

  },
  {
    path: '/detail/:id',
    name: 'detail',
    components: {
      default: Detail,
      appHeader: Navbar
    },
    meta: {
      title: '商品详情'
    }
  },
  {
    path: '/cart',
    name: 'cart',
    components: {
      default: Cart,
      appFooter: Tabbar
    }
  },
  {
    path: '/user',
    components: {
      default: User,
      appFooter: Tabbar
    }
  },
  {
    path: '/login',
    components: {
      default: Login
    }
  }
]

export default routes
